package com.qf.config;

import com.qf.pojo.common.MailBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
public class SendEmailUtil {

    @Value("${spring.mail.username}")
    public String username;


    @Autowired
    public JavaMailSender javaMailSender;


    public void sendManage(MailBean mailBean){
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setFrom(username);
        simpleMailMessage.setTo(mailBean.getRecipient());
        simpleMailMessage.setSubject(mailBean.getSubject());
        simpleMailMessage.setText(mailBean.getContent());
        javaMailSender.send(simpleMailMessage);
    }
}
